package pe.gob.inei.sirtod.domain;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;

import pe.gob.inei.sirtod.domain.pk.DatoMensualPK;
import pe.gob.inei.sirtod.util.DomainBase;

@Entity
@NamedNativeQueries(
	@NamedNativeQuery(name = "DatoMensual.findAll", query = "SELECT D_M.ANIO, D.ID_DEPARTAMENTO, D.DES_DEPARTAMENTO, "
		+ "D_M.INDICADOR_ID, MAX(M_1) AS M01, MAX(M_2) AS M02, MAX(M_3) AS M03, MAX(M_4) AS M04, "
		+ "MAX(M_5) AS M05, MAX(M_6) AS M06, MAX(M_7) AS M07, MAX(M_8) AS M08, MAX(M_9) AS M09, "
		+ "MAX(M_10) AS M10, MAX(M_11) AS M11, MAX(M_12) AS M12 FROM SIDIN_CONSULTA.DATO_MENS_DEP D_M "
		+ "LEFT OUTER JOIN SIDIN_CONSULTA.DEPARTAMENTO D ON D_M.ID_DEPARTAMENTO = D.ID_DEPARTAMENTO "
		+ "WHERE D.ID_DEPARTAMENTO IN (:lisDepSel) AND D_M.INDICADOR_ID IN (:lisIndSel) AND D_M.ANIO BETWEEN :txtAniIni "
		+ "AND :txtAniFin GROUP BY D_M.ANIO, D.ID_DEPARTAMENTO, D.DES_DEPARTAMENTO, D_M.INDICADOR_ID "
		+ "ORDER BY D.ID_DEPARTAMENTO, D_M.ANIO, D_M.INDICADOR_ID", resultClass = DatoMensual.class))
@SuppressWarnings("serial")
public class DatoMensual implements DomainBase {

	@EmbeddedId
	private DatoMensualPK pk;

	@Column(name = "DES_DEPARTAMENTO")
	private String departamento;

	@Column(name = "M01")
	private String valor01;

	@Column(name = "M02")
	private String valor02;

	@Column(name = "M03")
	private String valor03;

	@Column(name = "M04")
	private String valor04;

	@Column(name = "M05")
	private String valor05;

	@Column(name = "M06")
	private String valor06;

	@Column(name = "M07")
	private String valor07;

	@Column(name = "M08")
	private String valor08;

	@Column(name = "M09")
	private String valor09;

	@Column(name = "M10")
	private String valor10;

	@Column(name = "M11")
	private String valor11;

	@Column(name = "M12")
	private String valor12;

	public String getValue(int txtPerSel) {
		switch(txtPerSel) {
			case 1: return valor01;
			case 2: return valor02;
			case 3: return valor03;
			case 4: return valor04;
			case 5: return valor05;
			case 6: return valor06;
			case 7: return valor07;
			case 8: return valor08;
			case 9: return valor09;
			case 10: return valor10;
			case 11: return valor11;
			case 12: return valor12;
		}
		return null;
	}
	
	public String getPeriodo() {
		return pk.getPeriodo();
	}
	
	public Integer getIndicadorId() {
		return pk.getIndicadorId();
	}

	public DatoMensualPK getPk() {
		return pk;
	}

	public void setPk(DatoMensualPK pk) {
		this.pk = pk;
	}

	public String getDepartamento() {
		return departamento;
	}

	public void setDepartamento(String departamento) {
		this.departamento = departamento;
	}

	public String getValor01() {
		return valor01;
	}

	public void setValor01(String valor01) {
		this.valor01 = valor01;
	}

	public String getValor02() {
		return valor02;
	}

	public void setValor02(String valor02) {
		this.valor02 = valor02;
	}

	public String getValor03() {
		return valor03;
	}

	public void setValor03(String valor03) {
		this.valor03 = valor03;
	}

	public String getValor04() {
		return valor04;
	}

	public void setValor04(String valor04) {
		this.valor04 = valor04;
	}

	public String getValor05() {
		return valor05;
	}

	public void setValor05(String valor05) {
		this.valor05 = valor05;
	}

	public String getValor06() {
		return valor06;
	}

	public void setValor06(String valor06) {
		this.valor06 = valor06;
	}

	public String getValor07() {
		return valor07;
	}

	public void setValor07(String valor07) {
		this.valor07 = valor07;
	}

	public String getValor08() {
		return valor08;
	}

	public void setValor08(String valor08) {
		this.valor08 = valor08;
	}

	public String getValor09() {
		return valor09;
	}

	public void setValor09(String valor09) {
		this.valor09 = valor09;
	}

	public String getValor10() {
		return valor10;
	}

	public void setValor10(String valor10) {
		this.valor10 = valor10;
	}

	public String getValor11() {
		return valor11;
	}

	public void setValor11(String valor11) {
		this.valor11 = valor11;
	}

	public String getValor12() {
		return valor12;
	}

	public void setValor12(String valor12) {
		this.valor12 = valor12;
	}
}